#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int Judge_year(int year)
{
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
    {
        return 29;
    }
    else
    {
        return 28;
    }
}

void Judge_day(int year, int month, int day, int x[7], int y[4])
{
    int sum = 0;
    int a = 0;
    int b = 0;
    int spe = Judge_year(year);
    int i = 0;
    for (i = 0; i < 7; i++)
    {
        if (month > x[i])
        {
            a++;
        }
    }
    for (i = 0; i < 4; i++)
    {
        if (month > y[i])
        {
            b++;
        }
    }
    if (month > 2)
    {
        sum = a * 31 + b * 30 + spe + day;

    }
    else
    {
        sum = a * 31 + day;
    }
    printf("%d\n", sum);
}

int main()
{
    int year = 0;
    int month = 0;
    int day = 0;
    int Bigmonth[7] = { 1,3,5,7,8,10,12 };
    int Smallmonth[4] = { 4,6,9,11 };
    scanf("%d,%d,%d", &year, &month, &day);
    Judge_day(year, month, day, Bigmonth, Smallmonth);
    return 0;
}